<%@ page language="java" import="java.util.*,com.hs.wdss.model.*,com.hs.core.cache.*" pageEncoding="utf-8"%>
<%
	WdssDisinfo obj = (WdssDisinfo)request.getAttribute("obj");
	//List ptomlist = (List)request.getAttribute("ptomlist");
	List symlist = (List)request.getAttribute("symlist");
	List curelist = (List)request.getAttribute("curelist");
	List symselect = (List)request.getAttribute("symselect");
	List cureselect = (List)request.getAttribute("cureselect");
	
	
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script src="<%=basePath %>app/javascripts/transform.js"></script>
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script> 
<link rel="stylesheet" href="<%=basePath %>thirtpart/jquery/themes/demos.css"/> 
    <link rel="STYLESHEET" type="text/css" href="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcombo.css"/>
	
    <link rel="stylesheet" type="text/css" href="<%=basePath %>thirtpart/dhtmlx25/skins/dhtmlxlayout_dhx_blue.css"/>
    <script src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcommon.js"></script> 
	<script src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcontainer.js"></script>  
	<script  src="<%=basePath %>thirtpart/dhtmlx25/dhtmlxcombo.js"></script> 
    <script  src="<%=basePath %>thirtpart/dhtmlx25/ext/dhtmlxcombo_whp.js"></script>
    	<script  src="<%=basePath %>thirtpart/dhtmlx25/ext/dhtmlxcombo_extra.js"></script> 
     
<script language="javascript" type="text/javascript">
//证候相关方法
function savesymdata()
{
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	if(wdssid == ""){
		alert("请先保存医案信息！");	
		return;
	}else {
		var symname =  dwr.util.getValue("symname"); //document.getElementById("symname").value; 
		var memo = document.getElementById("memo").value; 
		var ptomobj = document.getElementsByName("ptom"); 
	    var ptomstr = "";
	    if("undefined" != typeof(ptomobj)){
			for(var i=0;i<ptomobj.length;i++){         
		      	if(ptomobj[i].checked){   
		          	  ptomstr += ptomobj[i].value+",";         
		        }         
	   		}
		} 
		var r = /^[0-9]*[1-9][0-9]*$/　　//正整数 
		if(!r.test(symname) || isNull(symname)){
			alert("请选择证候！");
			return; 
   		}
	   	dataProhelper.addSym(symname,memo,wdssid,ptomstr,callback4addSym);
	}
	
}
function callback4addSym(data){ 
	   var index = data.indexOf("$");
       var symid = data.substring(0,index);
       var symname = data.substring(index+1); 
       var str = "<span id=sym_"+symid+"><input type=radio onclick=viewCuremethod('"+symid+"') value="+symid+" name=sym><font size='5'>" + symname+"</font>&nbsp;&nbsp;<a href='javaScript:delSym("+symid+");'>删除</a>&nbsp;&nbsp;</span>";
       var objHtml = document.getElementById("syminfo");
       var temp = objHtml.innerHTML + str;
       objHtml.innerHTML = temp; 
       alert('证候信息保存成功！');   
       //document.getElementById("symname").value='';
       //dwr.util.setValue("symname","");
       z1.setComboValue('');
       document.getElementById("memo").value='';
       //document.getElementById("symname").focus(); 
       //刷新左边菜单
	 	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	 	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function delSym(id){
	if(confirm("确认要删除该证候吗？")){
    		dataProhelper.queryCurecout(id,callback4delsymcheck);
    }
}
function callback4delsymcheck(data){
	if("" == data){
		alert("请先删除该证候相关的治法");
		return; 
	}else{
		var wdssid = window.parent.datapromenu.document.all.wdssid.value;
		dataProhelper.delSym(data,wdssid,callback4delSym);
	} 
}
function callback4delSym(data){   
	document.getElementById("sym_"+data).style.display="none"; 
	//刷新左边菜单
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function viewCuremethod(id){ 
}
//返回
function backlist()
{
	window.parent.window.location.href = "<%=basePath%>produce/dataprolist.do"
}
//症状相关方法
function delPtom(id){
	if(confirm("确认要删除该症状吗？")){
    		dataProhelper.querySymmcout(id,callback4delcheck);
    }
}
function callback4delcheck(data){
	if("" == data){
		alert("请先删除该症状相关的证候");
		return; 
	}else{
		dataProhelper.delPtom(data,callback4delPtom);
	} 
}
function callback4delPtom(data){   
	document.getElementById("ptom_"+data).style.display="none"; 
	//刷新左边菜单
	 var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	 window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function viewSym(id){ 
}


//治法相关方法
function savecuredata()
{
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	if(wdssid == ""){
		alert("请先保存医案信息！");	
		return;
	}else {
		var curename =dwr.util.getValue("curename"); //document.getElementById("curename").value; 
		var symidvalue = "";
		var symid = getRadioValue("sym");
		if("undefined" != typeof(symid)){
			symidvalue = symid;
		} 
		var memo = document.getElementById("curememo").value; 
		var r = /^[0-9]*[1-9][0-9]*$/　　//正整数 
 		if(!r.test(curename)  || isNull(curename)){
			alert("请选择治法！");
			return; 
   		}
	   	dataProhelper.addCure(curename,memo,wdssid,symidvalue,callback4addCure);
	}
	
}
function callback4addCure(data){ 
	   var index = data.indexOf("$");
       var cureid = data.substring(0,index);
       var curename = data.substring(index+1);  
       var str = "<span id=cure_"+cureid+"><input type=radio onclick=viewCuremethod('"+cureid+"') value="+cureid+" name=cure><font size='5'>" + curename+"</font>&nbsp;&nbsp;<a href='javaScript:delCure("+cureid+");'>删除</a>&nbsp;&nbsp;</span>";
       var objHtml = document.getElementById("cureinfo");
       var temp = objHtml.innerHTML + str;
       objHtml.innerHTML = temp; 
       //dwr.util.setValue("curename","");
       
       alert('治法信息保存成功！');   
      // document.getElementById("curename").value='';
        z2.setComboValue('');
        document.getElementById("curememo").value='';
       //document.getElementById("curename").focus(); 
       //刷新左边菜单
	  var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	  window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function delCure(id){
	if(confirm("确认要删除该治法吗？")){
    		dataProhelper.queryPrecout(id,callback4delCurecheck);
    }
}
function callback4delCurecheck(data){
	if("" == data){
		alert("请先删除该治法相关的方剂");
		return; 
	}else{
		dataProhelper.delCure(data,callback4delCure);
	} 
}
function callback4delCure(data){   
	document.getElementById("cure_"+data).style.display="none"; 
	//刷新左边菜单
	var wdssid = window.parent.datapromenu.document.all.wdssid.value;
	window.parent.datapromenu.frameElement.src = "<%=basePath%>produce/datapromenu.do?wdssid="+wdssid;
}
function viewPremethod(id){ 
}
function doOnLoad() {
    
	
}
</script>
</head>
<body  >
<div class="current">当前位置：数据加工 &gt; 证候信息</div>
		
        <table border="0" cellspacing="0" cellpadding="0" class="news"> 
        <caption>
          证候信息
          </caption>
          <tr>
            <th width="15%">证候名称</th>
            <td width="35%"> 
             <select name="symname" id="symname" style="width:350px;">
             <option value=""></option>
             	<%if(symlist != null){
            		for(int i =0;i<symlist.size();i++){
            			Map data = (Map)symlist.get(i);
            			String id = (String)data.get("ID");
            			String value = (String)data.get("VALUE");
            			out.print("<option value=");
            			out.print(id);
            			if(id.equals(obj.getDisname())){
            				out.print(" selected");
            			}
            			out.print(" >");
            			out.print(value);
            			out.println("</option>");
            		} 
            	} %>
            </select>   
             <input name="disid" type="hidden" value=""/>
             <input name="discauseid" type="hidden" value=""/></td>
          
            <th width="15%">备注</th>
            <td width="35%"><input type="text" name="memo" id="memo" value="" style="width:99%"/>
            </td> 
          </tr>
          <tr> 
           <td colspan=4 align=center >
           		<input  type="button" value=" 保 存 " onclick="savesymdata();" class="butt"/>
           		<input  type="button" value=" 返 回 " onclick="backlist();" class="butt"/>
           </td>
          </tr>
        </table> 
       <table border="0" cellspacing="0" cellpadding="0"  class="news">
		  <tr>
		 	  <th width="15%">本医案已选择证候：</th>
	          <td width="85%" id="syminfo">
	           <%
	               if(symselect.size()>0){   
	                   for(int i =0;i<symselect.size();i++){ 
	          	             Map sym = (Map)symselect.get(i); 
	          	             String pid = (String)sym.get("ID"); 
	          	             String value = (String)sym.get("VALUE"); 
	          	             out.print("<span id=sym_"+pid+"><input type=radio onclick=viewCuremethod('"+pid+"') value="+pid+" name=sym><font size='5'>"+value+"</font>");
	          	             out.print("<a href=javaScript:delSym('"+pid+"');>");
	          	             out.print(" 删 除 </a></span>"); 
	           		}
	           	}
              %> 
	          </td>
          </tr>
        </table>
         <table border="0" cellspacing="0" cellpadding="0" class="news"> 
        <caption>
          治法信息
          </caption>
          <tr>
            <th width="15%">治法名称</th>
            <td width="35%">
               <select name="curename" id="curename" style="width:350px;"> 
               <option value=""></option>
            	<%if(curelist != null){
            		for(int i =0;i<curelist.size();i++){
            			Map data = (Map)curelist.get(i);
            			String id = (String)data.get("ID");
            			String value = (String)data.get("VALUE");
            			out.print("<option value=");
            			out.print(id);
            			if(id.equals(obj.getDisname())){
            				out.print(" selected");
            			}
            			out.print(" >");
            			out.print(value);
            			out.println("</option>");
            		} 
            	} %>
            </select>   
            
             <input name="disid" type="hidden" value=""/>
            <input name="discauseid" type="hidden" value=""/></td>
           
            <th width="15%">备注</th>
            <td width="35%"><input type="text" name="curememo" id="curememo" value="" style="width:99%"/>
            </td> 
          </tr>
          <tr> 
           <td colspan=4 align=center >
           		<input  type="button" value=" 保 存 " onclick="savecuredata();" class="butt"/>
           		<input  type="button" value=" 返 回 " onclick="backlist();" class="butt"/>
           </td>
          </tr>
        </table> 
        <table border="0" cellspacing="0" cellpadding="0"  class="news">
		  <tr>
		 	  <th width="15%">本医案已选治法：</th>
	          <td width="85%" id="cureinfo">
	           <%
	            if(cureselect.size()>0){   
	                   for(int i =0;i<cureselect.size();i++){ 
	          	             Map cure = (Map)cureselect.get(i); 
	          	             String pid = (String)cure.get("ID"); 
	          	             String value = (String)cure.get("VALUE"); 
	          	             out.print("<span id=cure_"+pid+"><input type=radio onclick=viewPremethod('"+pid+"') value="+pid+" name=cure><font size='5'>"+value+"</font>");
	          	             out.print("<a href=javaScript:delCure('"+pid+"');>");
	          	             out.print(" 删 除 </a></span>"); 
	           		}
	           	}
              %> 
	          </td>
          </tr>
        </table>
</body>
</html>

<script>
 window.dhx_globalImgPath="<%=basePath %>thirtpart/dhtmlx25/imgs/"; 
	//证候选择
	//var zhenghou=new dhtmlXCombo("zhenghou_div","symname",300);
	//var url = "<%=basePath %>dict/ajaxcombox.do?db_table=WDSS_STANDARD&col_id=id&col_name=STANDARDNAME&condition=CATEGORY="+encodeURIComponent('\'证候\'');
	//zhenghou.enableFilteringMode(true,url,true,false);
	//zhenghou.enableOptionAutoPositioning(true);	
	//zhenghou.enableFilteringMode(true);
	//zhenghou.loadXML(url);
	//zhenghou.readonly(false,true);  
	//治法选择
	//var zhifa=new dhtmlXCombo("zhifa_div","curename",300);
	//var urlzhifa = "<%=basePath %>dict/ajaxcombox.do?db_table=WDSS_STANDARD&col_id=id&col_name=STANDARDNAME&condition=CATEGORY="+encodeURIComponent('\'治法\'');
	//zhifa.enableFilteringMode(true,urlzhifa,true,false);
	//zhifa.enableOptionAutoPositioning(true);
	//zhifa.enableFilteringMode(true)
	//zhifa.loadXML(urlzhifa);
	//zhifa.readonly(false,true); 
		var z1 = dhtmlXComboFromSelect("symname");
		z1.enableFilteringMode(true);
		
		var z2 = dhtmlXComboFromSelect("curename");
		z2.enableFilteringMode(true);

</script>


